﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using net.veekee.common.data.csv;
using System.Collections;

namespace net.veekee.common.data
{
    public abstract class AFile : IDisposable
    {
        protected String fileName = null;
        public String FileName
        {
            get
            {
                return this.fileName;
            }
        }

        protected Dictionary<int, String> header = null;
        public Dictionary<int, String> Header
        {
            get
            {
                return this.header;
            }
        }

        protected ulong LineNumber = 0;

        public abstract bool IsValid
        {
            get;
        }

        public AFile(String filename)
        {
            this.fileName = filename;
            this.header = new Dictionary<int, String>();
        }

        public virtual void SelectSheet(String sheetName)
        {
        }

        public virtual void SelectSheet(int sheetID)
        {
        }

        public virtual void LoadHeader()
        {
        }

        public virtual List<Object> GetLine(ulong line)
        {
            return null;
        }

        public virtual void SetLine(ulong line, IEnumerator items)
        {
        }

        public virtual void SetLine(ulong line, List<Object> items)
        {
            if (items == null)
                return;
            this.SetLine(line, items.GetEnumerator());
        }

        public virtual void SetCell(ulong line, int column, Object item)
        {
        }

        public virtual AnEntry Next()
        {
            return default(AnEntry);
        }

        public virtual O Next<O>() where O : AnEntry, new()
        {
            O obj = (O)this.Next();
            if (obj != null)
                return default(O);
            return obj;
        }

        public virtual void Save()
        {
        }

        public virtual void Dispose()
        {
        }
    }
}
